package br.com.caelum.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Hora")
public class Hora extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
    public Hora() {
        super();
        System.out.println(" construtor");
    }

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	System.out.println(" service");
    	
    	PrintWriter out = response.getWriter();
    	SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    	
    	out.println("<html><body>");
    	out.println(sdf.format(Calendar.getInstance().getTime()));
    	out.println("</body></html>");
    	
	}
    
  @Override
public void init() throws ServletException {
	// TODO Auto-generated method stub
	super.init();
	System.out.println(" init");
}

}
